package org.springblade.common.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池工具类
 */
public class ThreadPoolUtil {
	private static final int THREAD_POOL_SIZE = 10;
	private static ExecutorService executorService = null;

	public static synchronized void executeTask(Runnable task) {
		if (executorService == null) {
			executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
		}
		executorService.execute(task);
	}

	public static synchronized void shutdown() {
		if (executorService != null) {
			executorService.shutdown();
			executorService = null;
		}
	}
}
